﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace University.Workshop.Presenters.WaterPurchase
{
    public class PresenterReadWaterPurchase
    {
        IReadBasicWaterPurchase viewReadBasic;
        Model.WaterPurchase newWaterPurchase = new Model.WaterPurchase();
        IReadPrincipalView view;

        public PresenterReadWaterPurchase(IReadPrincipalView View, Model.WaterPurchase waterPurchase)
        {
            view = View;
            newWaterPurchase = waterPurchase;           
        }

        public void FirstTime()
        {
            view.CallFirstPage();
            ProcedureAfterCall();
        }

        public void GoBackPage()
        {
            viewReadBasic.GoBackPage();
        }

        public void GoNextPage()
        {
            viewReadBasic.GoNextPage();
        }

        public void GoStepOne()
        {
            newWaterPurchase = view.ReadBasic.WaterPurchaseToRead;
            view.CallFirstPage();
            ProcedureAfterCall();
        }

        public void GoStepTwo()
        {
            newWaterPurchase = view.ReadBasic.WaterPurchaseToRead;
            view.CallSecondPage();
            ProcedureAfterCall();
        }

        private void ProcedureAfterCall()
        {

            if (viewReadBasic != null)
                newWaterPurchase = viewReadBasic.WaterPurchaseToRead;
            viewReadBasic = view.ReadBasic;
            viewReadBasic.WaterPurchaseToRead = newWaterPurchase;
            viewReadBasic.Update();
        }
    }
}
